﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.Assembler.x86.x87;

namespace DimOS.Plugs
{
    public static class Math
    {
        public static float Round(this float value)
        { if (value == 0) return value; if (value > 0) { var checker =
          Convert.ToInt32(value) + 1; if (Convert.ToInt32(value + 0.5f)
          == checker) return checker; return checker - 1; } else { var
          checker = Convert.ToInt32(value) - 1; if (Convert.ToInt32
          (value - 0.5f) == checker) return checker; return checker + 1; } }

        public static float Ceiling(this float value)
        { if (value == 0 || Convert.ToInt32(value) == value) return value; if (value
          > 0) return Convert.ToInt32(value) + 1; return Convert.ToInt32(value); }

        public static float Floor(this float value)
        { if (value == 0 || Convert.ToInt32(value) == value) return value; if (value
          < 0) return Convert.ToInt32(value) - 1; return Convert.ToInt32(value); }

        public static float Remainder(float source, float target)
        { return (source - (target * Convert.ToInt32(source / target))); }
    }
}
